﻿using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Easy.Model
{
    /// <summary>
    /// 实体引用
    /// </summary>
    public class EntityReference
    {
        public Guid? id { get; set; }
        public string name { get; set; }
        public string entityname { get; set; }
    }

    /// <summary>
    /// 选项集对象
    /// </summary>
    public class OptionSet
    {
        public int Value { get; set; }
        public string Text { get; set; }
    }

    /// <summary>
    /// 字段
    /// </summary>
    public class Field
    {
        public string Name { get; set; }
        public string DisplayName { get; set; }
        public bool? IsPrimaryAtt { get; set; }

        [JsonConverter(typeof(StringEnumConverter))]
        public FieldType? Type { get; set; }

        //Alter By xlxu nvarchar字段长度 max也可以 所以定义成string类型
        public string Length { get; set; }
        public bool? IsNullable { get; set; }
        public FieldFormat? Format { get; set; }
        public bool? Cansearchable { get; set; }
        public string LookupEntityName { get; set; }
        public string LookupPrimaryAtt { get; set; }

        public bool? IsGlobalPicklist { get; set; }
        public string GlobalPicklist { get; set; }

        //Alter By xlxu 字段长度
        public string AttributeWidth { get; set; }

        //Alter By xlxu 视图默认排序字段 （asc||desc）
        public string ViewOrderBy { get; set; }

        //Alter By kyzhao 字段对应实体（主实体，lookup实体）
        public string EntityName { get; set; }

    }

    /// <summary>
    /// 字段类型
    /// </summary>
    public enum FieldType
    {
        key, nvarchar, picklist, bit, @int, @float, ntext, date, datetime, lookup, password, image
    }
    /// <summary>
    /// 字段类型分类：文本型，数值型，lookup对象型
    /// </summary>
    public enum FieldCategoryType
    {
        Text, Number, Lookup
    }

    /// <summary>
    /// 字段格式
    /// </summary>
    public enum FieldFormat
    {

    }

    /// <summary>
    /// 属性
    /// </summary>
    public class Attribute
    {
        public string Name { get; set; }
        public object Value { get; set; }
    }

}
